<template>
  <div v-if="!userStore.isLogin" class="personalized-recommendation">
    <div class="recommendation-content">
      <h2 class="title">{{ $t('查看个性化推荐') }}</h2>
      <el-button class="sign-in-button" type="primary" @click="handleLogin">{{ $t('立即登录') }}</el-button>
      <div class="new-customer">{{ $t('新用户？') }}<router-link to="/register">{{ $t('立即注册') }}</router-link></div>
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent } from 'vue'
import { useRouter } from 'vue-router'
import useUserStore from '@/store/modules/user'

export default defineComponent({
  name: 'PersonalizedRecommendation',
  setup() {
    const router = useRouter()
    const userStore = useUserStore()

    const handleLogin = () => {
      router.push('/login')
    }

    return {
      handleLogin,
      userStore
    }
  }
})
</script>

<style lang="scss" scoped>
.personalized-recommendation {
  width: 100%;
  background-color: #fff;
  padding: 20px 0;
  margin: 20px 0;

  .recommendation-content {
    text-align: center;
    max-width: 300px;
    margin: 0 auto;
    padding: 20px 0;
  }

  .title {
    font-size: 18px;
    color: #0F1111;
    margin-bottom: 16px;
    font-weight: 500;
  }

  .sign-in-button {
    width: 100%;
    height: 40px;
    font-size: 14px;
    margin-bottom: 12px;
    background: linear-gradient(to bottom, #f7dfa5, #f0c14b);
    border-color: #a88734 #9c7e31 #846a29;
    color: #111;

    &:hover {
      background: linear-gradient(to bottom, #f5d78e, #eeb933);
    }
  }

  .new-customer {
    font-size: 13px;
    color: #565959;

    a {
      color: #0066c0;
      text-decoration: none;
      margin-left: 4px;

      &:hover {
        color: #c45500;
        text-decoration: underline;
      }
    }
  }
}

@media (max-width: 768px) {
  .personalized-recommendation {
    margin: 15px 0;

    .recommendation-content {
      padding: 15px;
    }
  }
}
</style>
